/******************************************************************************
 * (C) 671643387@qq.com
 */

#include "Thread.h"
#include "Session.h"

namespace Shared {
    namespace Net {

        Thread::Thread()
            : _load(0)
            , _thread()
            , _socketReactor() {

        }

        Thread::~Thread() {

        }

        void Thread::start() {
            _thread.start(*this);
        }

        void Thread::stop() {
            _socketReactor.stop();
        }

        void Thread::join() {
            _thread.join();
        }

        void Thread::addSession(Session *session) {
            _load += 1;
            session->bindThread(this);
        }

        void Thread::removeSession(Session *session) {
            session->unbindThread();
            _load -= 1;
        }

        void Thread::run() {
            _socketReactor.run();
        }

    }
}